/**
 * User: yforward
 * Date: 2018/12/7
 * Time: 5:23 PM
 */

import axios from 'axios'
import {configObj} from '@/utils/config.js'
const ajaxURL = {}

 /**
 * 封装get方法
 * @param url
 * @param data
 * @returns {Promise}
 */

export function get(url,params={}){
    return new Promise((resolve,reject) => {
        axios({
            method: 'get',
            url: ajaxURL[url],
            params: params,
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(res => {
            return resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


/**
 * 封装post请求
 * @param url
 * @param data
 * @returns {Promise}
 */

export function post(url,data = {}){
    return new Promise((resolve,reject) => {
        axios({
            method: 'get',
            url: ajaxURL[url],
            data: data,
            headers: {
                'Content-Type': 'application/json'
            }
        }).then(res => {
            return resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


export default {
    get,
    post
}